/*! \file OrbitEvent.h
 *	\brief <write description for OrbitEvent.h>
 *
 *	created:	2010/09/08
 *	created:	8:9:2010   12:35
 *	filename: 	s:\DNG-Code\Kiev\Modules\Orbit\Protection\Include\OrbitEvent.h
 *	file path:	s:\DNG-Code\Kiev\Modules\Orbit\Protection\Include
 *	file base:	OrbitEvent
 *	file ext:	h
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#ifndef _protection_ORBITEVENT_H_
#define _protection_ORBITEVENT_H_

#pragma once

namespace tt{
namespace core{

#include <algorithm>
#include <vector>

#include "Functors.h"

//////////////////////////////////////////////////////////////////////////
template<typename HandlerTy>
class EventBase
{
public:
	typedef HandlerTy Handler;

	EventBase();
    ~EventBase();

    EventBase& operator += ( const Handler& handler );

protected:
	typedef std::vector<Handler> Handlers;
    Handlers m_handlers;
};

//////////////////////////////////////////////////////////////////////////
template<typename Handler>
class Event : public EventBase<Handler>
{
};

//////////////////////////////////////////////////////////////////////////
template<>
class Event<Functor0> : public EventBase<Functor0>
{
public:
	void operator() ();
};

//////////////////////////////////////////////////////////////////////////
template<typename Arg1>
class Event< Functor1<Arg1> > : public EventBase< Functor1<Arg1> >
{
public:
	void operator() (Arg1);
};

//////////////////////////////////////////////////////////////////////////
template<typename Arg1, typename Arg2>
class Event< Functor2<Arg1, Arg2> > : public EventBase< Functor2<Arg1, Arg2> >
{
public:
	void operator() (Arg1, Arg2);
};

} //namespace core
} //namespace tt
#include "Event.inl"

#endif //_protection_ORBITEVENT_H_
